package main.java.com.service.impl;

import main.java.com.config.PageInfo;
import main.java.com.dao.CategoryTwoDao;
import main.java.com.dao.impl.CategoryTwoDaoImpl;
import main.java.com.entity.Category;
import main.java.com.service.CategoryTwoService;

public class CategoryTwoServiceImpl implements CategoryTwoService {
    CategoryTwoDao categoryDao = new CategoryTwoDaoImpl();
    /**
     * 展示数据库信息
     *
     * @return 分类管理对象
     */
    @Override
    public PageInfo<Category> showInfo(int pageNum, int pageSize) {
        PageInfo<Category> pageInfo = new PageInfo<>();
        pageInfo.setPageSize(pageSize);
        pageInfo.setCurrPageNo(pageNum);
        //查询总条数
        pageInfo.setTotals(categoryDao.getPageCount());
        int startIndex= (pageInfo.getCurrPageNo() - 1 ) * pageInfo.getPageSize();
        pageInfo.setList(categoryDao.showinfo(startIndex,pageInfo.getPageSize()));
        return pageInfo;
    }

    /**
     * 添加套餐
     * @param category
     * @return
     */
    @Override
    public int adddish(Category category) {
        return categoryDao.adddish(category);
    }

    /**
     * 添加菜品
     * @param category
     * @return
     */
    @Override
    public int addpop(Category category) {
        return categoryDao.addpop(category);
    }

    /**
     * 删除菜品
     * @param id
     * @return
     */
    @Override
    public int deletdish(Long id) {
        return categoryDao.deletdish(id);
    }

    /**
     * 修改菜品
     * @param category
     * @return
     */
    @Override
    public int updatedish(Category category) {
        return categoryDao.updatedish(category);
    }
}
